package com.cqc.listactivityfragment01;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

import static android.content.ContentValues.TAG;

/**
 * Created by cui on 2017/3/20.
 */

public class ListActivity extends android.app.ListActivity {
    private List<String> list = new ArrayList<>();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list);

        for (int i = 0; i < 100; i++) {
            list.add("ListActivity：自定义item布局" + i);
        }

        setListAdapter(new ArrayAdapter<String>(ListActivity.this, android.R.layout.simple_list_item_1, list));
    }

    /**
     * ListView的点击事件
     */
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        String text = (String) l.getItemAtPosition(position);
        Log.d(TAG, "ListActivity--text=" + text);
        startActivity(new Intent(ListActivity.this,ListFragActivity.class));
    }
}
